<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title>3.模拟一个Vue中的数据代理</title>
  </head>
  <body>
    <script type="text/javascript" >
      let vm = {
        $xxxx:'xxxx',
        _xxxxx:'xxx',
        _data:{
          school:'尚硅谷',
          address:'宏福科技园'
        }
      }

      const keys = Object.keys(vm._data)

      keys.forEach((item)=>{
        Object.defineProperty(vm,item,{
          get(){
            return vm._data[item]
          },
          set(value){
            vm._data[item] = value
          }
        })
      })

      console.log(vm)
      
    </script>
  </body>
</html>